package com.huan.quartz.quartz;

import com.huan.quartz.service.QuartzJobCfgService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * quartz job 初始化
 *
 * @author huan.fu
 * @date 2018/9/10 - 17:11
 */
@Component
public class QuartzJobLoader implements InitializingBean {

	@Autowired
	private QuartzJobCfgService quartzJobCfgService;
	@Autowired
	private QuartzService quartzService;

	@Override
	public void afterPropertiesSet() {
		quartzJobCfgService
				.findAll()
				.forEach(job -> quartzService.addQuartzJob(job));
	}
}
